package com.lyc.common.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.codec.JsonJacksonCodec;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

/**
 * redis客户端Redission配置
 * @Author 李大神仙
 * @Date 2024/2/26 21:15
 * @Version 1.0
 */

@Configuration
public class RedissionConfig {
    @Value("${spring.redis.host}")
    private String redisHost;

    @Value("${spring.redis.password}")
    private String password;

    @Value("${spring.redis.port}")
    private String port;

    public RedissonClient getRedisson(){
        Config config = new Config();
        config.useSingleServer()
                .setAddress("redis://"+redisHost+":"+port)
                .setPassword(password);
        config.setCodec(new JsonJacksonCodec());
        return Redisson.create(config);
    }
}
